package com.studyadmin.controller;


import com.studyadmin.entity.Message;
import com.studyadmin.entity.Student;
import com.studyadmin.service.MessageService;
import com.studyadmin.service.RoleService;
import com.studyadmin.service.StudentService;
import com.studyadmin.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 消息表 前端控制器
 * 用来发送消息
 * </p>
 *
 * @author lyl
 * @since 2023-03-30
 */
@RestController
@RequestMapping("/studyadmin/message")
@CrossOrigin
public class MessageController {

@Autowired
    MessageService messageService;

    /**
     * 发送消息
     * @param message 发送者  接受者
     * @return
     */
    @PostMapping("/sendMsg")
    public JsonUtil sendMsg(@RequestBody Message message){
        return messageService.sendMsgSer(message);
    }

    /**
     * 显示历史消息
     * @param senderNum
     * @return
     */
    @GetMapping ("/historyMsg")
    public JsonUtil historyMsg(@RequestParam(value = "senderNum") String senderNum,
                               @RequestParam(value = "receiveNum") String receiveNum){
        System.out.println("发送者num"+senderNum+receiveNum);
        return messageService.historyMsgSer(senderNum,receiveNum);
    }
    /**
     * 消息设置成已读
     * @param
     * @return
     */
    @GetMapping ("/MsgRead")
    public JsonUtil msgRead(@RequestParam(value = "teaNum") String teaNum,
                               @RequestParam(value = "stuNum") String stuNum){
//        System.out.println("发送者num"+senderNum);
        return messageService.msgReadSer(teaNum,stuNum);
    }






}

